/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cardgame;

import cardgame.game.*;

/**
 *
 * @author Carl
 */
public abstract class CardChooserManager{

    public CardChooserManager(){
        manaChooser = new ManaChooser(this);
        spellParameterChooser = new SpellParameterChooser(this);
        attackTargetChooser = new AttackTargetChooser(this);
        throwingOffChooser = new ThrowingOffChooser(this);
    }
    protected CardChooser activeCardChooser;
    private ManaChooser manaChooser;
    private SpellParameterChooser spellParameterChooser;
    private AttackTargetChooser attackTargetChooser;
    private ThrowingOffChooser throwingOffChooser;
    
    public void startChoosing_SummonMonsterCost(int playerIndex, MonsterCard monsterCard, int hand_MonsterCardIndex){
        manaChooser.start(ManaChooser.ManaChooseType.MONSTER_SUMMON_COST, playerIndex, new int[]{hand_MonsterCardIndex}, monsterCard.getSummonCost().getMana());
        start(manaChooser);
    }
    
    public void startChoosing_MonsterSpellCost(int playerIndex, Spell spell, int spell_MonsterCardIndex, int spell_SpellIndex){
        manaChooser.start(ManaChooser.ManaChooseType.MONSTER_SPELL_COST, playerIndex, new int[]{spell_MonsterCardIndex, spell_SpellIndex}, spell.getCost().getMana());
        start(manaChooser);
    }
    
    public void startChoosing_SpellCost(int playerIndex, Spell spell, int handCardIndex){
        manaChooser.start(ManaChooser.ManaChooseType.SPELL_COST, playerIndex, new int[]{handCardIndex}, spell.getCost().getMana());
        start(manaChooser);
    }
    
    public void startChoosing_MonsterSpellParameter(Spell spell, int spell_MonsterCardIndex, int spell_SpellIndex, int[] spell_ManaIndices){
        spellParameterChooser.start(SpellParameterChooser.SpellChooseType.MONSTER_SPELL, spell, new int[]{spell_MonsterCardIndex, spell_SpellIndex}, spell_ManaIndices);
        start(spellParameterChooser);
    }
    
    public void startChoosing_SpellParameter(Spell spell, int handCardIndex, int[] spell_ManaIndices){
        spellParameterChooser.start(SpellParameterChooser.SpellChooseType.SPELL, spell, new int[]{handCardIndex}, spell_ManaIndices);
        start(spellParameterChooser);
    }
    
    public void startChoosing_AttackTarget(int playerIndex, int attack_MonsterCardIndex){
        attackTargetChooser.start(playerIndex, attack_MonsterCardIndex);
        start(attackTargetChooser);
    }
    
    public void startChoosing_ThrowingOff(int playerIndex){
        throwingOffChooser.start(playerIndex);
        start(throwingOffChooser);
    }
    
    protected void start(CardChooser cardChooser){
        activeCardChooser = cardChooser;
    }

    public void stop(){
        activeCardChooser.stop();
        activeCardChooser = null;
        setMessage(null);
    }

    public CardChooser getActiveCardChooser(){
        return activeCardChooser;
    }
    
    public abstract void setMessage(String text);
}
